package com.taotao.inventory.controller;

import java.util.List;
import java.io.IOException;


import com.taotao.inventory.domain.vo.OrderVo;
import com.taotao.inventory.domain.vo.PurchaseDemandVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.taotao.common.security.annotation.RequiresPermissions;
import com.taotao.inventory.domain.TSkuInfo;
import com.taotao.inventory.service.ITSkuInfoService;
import com.taotao.common.core.web.controller.BaseController;
import com.taotao.common.core.domain.Result;


/**
 * 库存预警Controller
 *
 * @author byf
 * @date 2025-01-14
 */
@RestController
@RequestMapping("/inventory")
public class TSkuInfoController extends BaseController
{
    @Autowired
    private ITSkuInfoService tSkuInfoService;

    /**
     * 查询库存预警列表
     */
    @RequiresPermissions("inventory:inventory:list")
    @GetMapping("/list")
    public Result list(TSkuInfo tSkuInfo)
    {
        startPage();
        List<TSkuInfo> list = tSkuInfoService.selectTSkuInfoList(tSkuInfo);
        return getDataTable(list);
    }

    /**
     * 添加采购需求
     * @param skuId
     * @return
     */
    @RequiresPermissions("inventory:inventory:add")
    @PostMapping("/Increase")
    public Result Increase(@RequestBody Long skuId)
    {
        return tSkuInfoService.Increase(skuId);
    }


    //根据supplierId 查询需求数据数据
    @RequiresPermissions("inventory:inventory:list")
    @GetMapping("/selectSuppliceId/{supplierId}")
    public Result selectSuppilerById(@PathVariable Long supplierId)
    {
        startPage();
        List<PurchaseDemandVo> list = tSkuInfoService.selectSuppilerById(supplierId);
        return getDataTable(list);
    }

    /**
     * 添加订单
     * @param orderVo
     * @return
     */
    @RequiresPermissions("inventory:inventory:add")
    @PostMapping("/orderAdd")
    public Result add(@RequestBody OrderVo orderVo)
    {
        return tSkuInfoService.orderAdd(orderVo);
    }


    /**
     * 对订单进行审核
     * @param id
     * @return
     */
    @GetMapping("/applyId/{id}")
    public Result applyId(@PathVariable Long id)
    {
        return tSkuInfoService.applyId(id);
    }


}
